package a.g;

import a.c.y;
import a.c.z;
import a.i.n;

import javax.swing.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;

public class gb
{
  protected String a;
  protected Hashtable b;
  protected z c;
  protected z d;
  protected PropertyChangeSupport e = new PropertyChangeSupport(this);
  public static int f;
  
  public gb(String paramString)
  {
    this.a = paramString;
    a();
  }
  
  public gb(InputStream paramInputStream)
  {
    a();
    a(paramInputStream);
  }
  
  public gb(URL paramURL)
  {
    a();
    try
    {
      String str = System.getProperty("y.package");
      if (f.p == 0)
      {
        if (str != null) {
          str = "file://" + str;
        }
      }
      else
      {
        n.a(str);
        paramURL = new URL(str);
      }
    }
    catch (Exception localException1) {}
    try
    {
      InputStream localInputStream = paramURL.openStream();
      a(localInputStream);
    }
    catch (Exception localException2)
    {
      n.a("Package Initialization Problem: \n" + localException2);
    }
  }
  
  private void a()
  {
    this.b = new Hashtable();
    this.c = new z();
    this.d = new z();
  }
  
  public void a(InputStream paramInputStream)
  {
    int k = f.p;
    boolean bool = f.o;
    int i = 0;
    StringBuffer localStringBuffer = new StringBuffer();
    try
    {
      BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramInputStream));
      do
      {
        do
        {
          int j;
          if ((j = localBufferedReader.read()) == -1) {
            break;
          }
          localStringBuffer.append((char)j);
          if ((k == 0) && (bool)) {
            break label82;
          }
        } while (!bool);
      } while (k != 0);
      localBufferedReader.close();
    }
    catch (IOException localIOException)
    {
      label82:
      n.b(localIOException);
    }
    kb localkb = new kb(localStringBuffer.toString());
    Properties localProperties = c.a(localkb, "PACKAGE");
    n.a(this, "PACKAGE properties:" + localProperties);
    this.a = localProperties.getProperty("name", "NONAME");
    a(localkb);
  }
  
  public static gb a(String paramString)
  {
    return new gb(a.i.kb.b(paramString));
  }
  
  void a(kb paramkb)
  {
    int j = f.p;
    boolean bool = f.o;
    n.a(this, ">>>initPackage(XMLTok)");
    int i = 1;
    label243:
    do
    {
      String str4;
      do
      {
        String str3;
        do
        {
          do
          {
            String str2;
            do
            {
              do
              {
                for (;;)
                {
                  if (i == 0) {
                    break label657;
                  }
                  Properties localProperties = new Properties();
                  String str1 = c.a(paramkb, localProperties);
                  n.a(this, "TAG properties:" + localProperties);
                  n.a(this, "nextTag = " + str1);
                  if (((j == 0) && (str1 == null)) || ((j == 0) && (str1.equals("/PACKAGE")))) {
                    break label657;
                  }
                  if (j == 0) {
                    if (str1.equals("PACKAGE"))
                    {
                      str2 = localProperties.getProperty("external");
                      str3 = localProperties.getProperty("stable");
                      str4 = localProperties.getProperty("class");
                      n.a(this, "pClass=" + str4 + " external=" + str2 + " stable=" + str3);
                      if (j == 0) {
                        if (str3 != null)
                        {
                          if (j != 0) {
                            break label243;
                          }
                          if (!Boolean.valueOf(str3).booleanValue())
                          {
                            c.a(paramkb, "/PACKAGE");
                            if (j != 0) {
                              continue;
                            }
                            if (!bool) {
                              continue;
                            }
                          }
                        }
                      }
                      Object localObject;
                      if (j == 0) {
                        if (str2 != null)
                        {
                          localObject = getClass().getClassLoader().getResourceAsStream(str2);
                          if (localObject != null)
                          {
                            gb localgb2 = new gb((InputStream)localObject);
                            a(localgb2);
                            if (j != 0) {
                              break label332;
                            }
                            if (!bool) {}
                          }
                          else
                          {
                            System.err.println("Cannot find referenced Package: " + str2);
                          }
                          c.a(paramkb, "/PACKAGE");
                          if (j != 0) {
                            break label444;
                          }
                          if (!bool) {
                            break label437;
                          }
                        }
                      }
                      if ((j != 0) || (str4 != null))
                      {
                        try
                        {
                          localObject = (gb)Class.forName(str4).newInstance();
                          a((gb)localObject);
                        }
                        catch (Exception localException1)
                        {
                          n.a(this, "Can't load package " + str4);
                          if (j != 0) {
                            break label444;
                          }
                        }
                        if (!bool) {}
                      }
                      else
                      {
                        gb localgb1 = new gb(localProperties.getProperty("name", "NONAME"));
                        localgb1.a(paramkb);
                        a(localgb1);
                      }
                    }
                  }
                  if (str1.equals("MODULE"))
                  {
                    str2 = localProperties.getProperty("stable");
                    str3 = localProperties.getProperty("name");
                    str4 = localProperties.getProperty("class");
                    n.a(this, "classname=" + str4 + " name=" + str3 + " stable=" + str2);
                    if ((j != 0) || (bool)) {
                      return;
                    }
                    if (j != 0) {
                      break label577;
                    }
                    if (str4 == null) {
                      break label575;
                    }
                    try
                    {
                      Class.forName(str4);
                    }
                    catch (Exception localException2)
                    {
                      c.a(paramkb, "/MODULE");
                    }
                    catch (NoClassDefFoundError localNoClassDefFoundError)
                    {
                      c.a(paramkb, "/MODULE");
                    }
                  }
                }
              } while (j != 0);
            } while (!bool);
            if (j != 0) {
              break label620;
            }
            if (str2 == null) {
              break;
            }
            if (j != 0) {
              break label620;
            }
            if (Boolean.valueOf(str2).booleanValue()) {
              break;
            }
            c.a(paramkb, "/MODULE");
          } while (j != 0);
        } while (!bool);
        if (str3 == null) {
          break;
        }
        a(str3, str4);
        if (j != 0) {
          break label654;
        }
      } while (!bool);
      if (j != 0) {
        break label660;
      }
      c(str4);
    } while (!bool);
    label332:
    label620:
    n.a(this, "<<<initPackage(XMLTok)");
    label437:
    label444:
    label575:
    label577:
    return;
  }
  
  public String b()
  {
    return this.a;
  }
  
  public f b(String paramString)
  {
    int i = f.p;
    Object localObject = this.b.get(paramString);
    if (i == 0) {
      if ((localObject instanceof f)) {
        return (f)localObject;
      }
    }
    if ((i != 0) || ((localObject instanceof String))) {
      try
      {
        Class localClass = Class.forName((String)localObject);
        f localf = (f)localClass.newInstance();
        this.b.remove(localObject);
        this.b.put(paramString, localf);
        return localf;
      }
      catch (Exception localException) {}
    }
    return null;
  }
  
  public y c()
  {
    return this.c.h();
  }
  
  public y d()
  {
    return this.d.h();
  }
  
  public Hashtable e()
  {
    return this.b;
  }
  
  public void a(f paramf)
  {
    a(paramf.a(), paramf);
  }
  
  public void a(String paramString, f paramf)
  {
    this.b.put(paramString, paramf);
    this.c.add(paramString);
    this.e.firePropertyChange("moduleList", null, null);
  }
  
  public void c(String paramString)
  {
    int j = f.p;
    int i = paramString.lastIndexOf('.');
    if (j == 0)
    {
      if (i < 0)
      {
        if (j != 0) {
          break label48;
        }
        a(paramString, paramString);
      }
    }
    else if (!f.o) {
      return;
    }
    label48:
    a(paramString, paramString.substring(i + 1, paramString.length()));
  }
  
  public void a(String paramString1, String paramString2)
  {
    this.b.put(paramString1, paramString2);
    this.c.add(paramString1);
    this.e.firePropertyChange("moduleList", null, null);
  }
  
  public void d(String paramString)
  {
    this.b.remove(paramString);
    this.c.remove(paramString);
    this.e.firePropertyChange("moduleList", null, null);
  }
  
  public void a(gb paramgb)
  {
    this.d.add(paramgb);
    this.e.firePropertyChange("packageList", null, null);
  }
  
  public void b(gb paramgb)
  {
    this.d.remove(paramgb);
    this.e.firePropertyChange("packageList", null, null);
  }
  
  public JMenu a(ib paramib)
  {
    hb localhb = new hb(this, paramib);
    return localhb.a();
  }
  
  public void a(JMenu paramJMenu, ib paramib)
  {
    hb localhb = new hb(this, paramib);
    localhb.a(paramJMenu);
  }
  
  public void f()
  {
    boolean bool = f.o;
    System.out.println("package " + b() + ": currently loaded modules:");
    Enumeration localEnumeration = this.b.keys();
    do
    {
      if (!localEnumeration.hasMoreElements()) {
        break;
      }
      String str = (String)localEnumeration.nextElement();
      System.out.println(" " + str);
    } while (!bool);
  }
  
  public void a(PropertyChangeListener paramPropertyChangeListener)
  {
    this.e.addPropertyChangeListener(paramPropertyChangeListener);
  }
  
  public synchronized void b(PropertyChangeListener paramPropertyChangeListener)
  {
    this.e.removePropertyChangeListener(paramPropertyChangeListener);
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.g.gb

 * JD-Core Version:    0.7.0.1

 */